package kitread.model;

import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

import com.sun.syndication.io.FeedException;

public class FeedsCollection extends LinkedList<FeedItem> {

	private static final long serialVersionUID = -2697962155480668494L;
	private Set<Feed> feeds = new HashSet<Feed>();
	
	public Set<Feed> getFeeds() {
		return feeds;
	}
	
	public void addFeed(Feed f) {
		feeds.add(f);
	}
	
	public void refresh() throws IllegalArgumentException, FeedException, IOException {
		clear();
		for(Feed f : feeds) {
			f.refresh();
			addAll(f);
		}
		Collections.sort(this, FeedItemComparator.instance());
	}
}
